package com.hyjx.framework.common.tree;

import java.util.ArrayList;
import java.util.List;

/**
 * 树型结构数据对象
 *
 * @author dijian
 */
public class TreeObject {
    /**
     * 节点id
     */
    private String id;
    /**
     * 节点代码
     */
    private String code;
    /**
     * 父节点代码
     */
    private String parent_id;
    /**
     * 节点显示名称
     */
    private String text;
    /**
     * 节点对象的链接地址
     */
    private String url;
    /**
     * 节点的子节点信息
     */
    private List<TreeObject> children;
    /**
     * 节点的展开关闭状态
     */
    private String state = "open";
    /**
     * 节点的复选状态
     */
    private boolean checked = false;
    /**
     * 节点的属性信息
     */
    private String attributes;
    /**
     * 节点的选中状态
     */
    private boolean selected = false;
    /**
     * 是否为叶子节点
     */
    private String endflag;
    /**
     *
     */
    private String levelId;

    /**
     * 判断当前节点是否选中
     *
     * @return
     */
    public boolean isSelected() {
        return selected;
    }

    /**
     * 设置当前节点为选中状态
     *
     * @param selected
     */
    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    /**
     * 获得树节点的属性信息
     *
     * @return
     */
    public String getAttributes() {
        return attributes;
    }

    /**
     * 设置当前节点的属性信息
     *
     * @param attributes
     */
    public void setAttributes(String attributes) {
        this.attributes = attributes;
    }

    /**
     * 获取当前节点的状态
     *
     * @return
     */
    public String getState() {
        return state;
    }

    /**
     * 设置当前节点的状态
     *
     * @param state 状态值
     */
    public void setState(String state) {
        this.state = state;
    }

    /**
     * 向节点添加子节点
     *
     * @param obj
     */
    public void addChild(TreeObject obj) {
        if (this.children == null) {
            this.children = new ArrayList<TreeObject>();
        }
        this.children.add(obj);
    }

    /**
     * 判断当前节点是否有子节点
     *
     * @return
     */
    public boolean hasChild() {
        if (this.children == null || this.children.size() == 0) {
            return false;
        } else {
            return true;
        }
    }

    /**
     * 获取当前节点的子节点列表
     *
     * @return
     */
    public List<TreeObject> getChildren() {
        if (children == null)
            children = new ArrayList<TreeObject>();
        return children;
    }

    /**
     * 设置当前节点的子节点
     *
     * @param children
     */
    public void setChildren(List<TreeObject> children) {
        this.children = children;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getParent_id() {
        return parent_id;
    }

    public void setParent_id(String parent_id) {
        this.parent_id = parent_id;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }


    public boolean isChecked() {
        return checked;
    }


    public void setChecked(boolean checked) {
        this.checked = checked;
    }


    public String getUrl() {
        return url;
    }


    public void setUrl(String url) {
        this.url = url;
    }


    public String getCode() {
        return code;
    }


    public void setCode(String code) {
        this.code = code;
    }


    public String getEndflag() {
        return endflag;
    }


    public void setEndflag(String endflag) {
        this.endflag = endflag;
    }

    public String getLevelId() {
        return levelId;
    }

    public void setLevelId(String levelId) {
        this.levelId = levelId;
    }

}
